import cv2
import numpy as np
img = cv2.imread('../IMAGES/j.png',0)

cv2.imshow('img' ,img)

kernel = np.ones((5,5),np.uint8)
erosion = cv2.erode(img,kernel,iterations = 1)

cv2.imshow('erosion' ,erosion)

dilation = cv2.dilate(img,kernel,iterations = 1)
cv2.imshow('dilation' ,dilation)

gradient = cv2.morphologyEx(img, cv2.MORPH_GRADIENT, kernel)
cv2.imshow('gradient' ,gradient)

k = cv2.waitKey(0)
if k == 27:         # wait for ESC key to exit
    cv2.destroyAllWindows()
